package com.mall.sun.service.impl;

import com.mall.sun.model.dto.BaseChartDTO;
import com.mall.sun.model.dto.UserAdviceDTO;
import com.mall.sun.model.po.Useradvice;
import com.mall.sun.repository.mapper.UseradviceMapper;
import com.mall.sun.service.UseradviceService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Tansty
 * @since 2021-11-30
 */
@Service
public class UseradviceServiceImpl extends ServiceImpl<UseradviceMapper, Useradvice> implements UseradviceService {
    @Autowired
    UseradviceMapper useradviceMapper;
    @Override
    public UserAdviceDTO[] getOrderAdvice(Integer orderId) {
        return useradviceMapper.getOrderAdvice(orderId);
    }

    @Override
    public UserAdviceDTO[] getUserAdvice(Integer userId) {
        return useradviceMapper.getUserAdvice(userId);
    }

    @Override
    public BaseChartDTO[] countAdvice() {
        BaseChartDTO[] baseChartDTOS = useradviceMapper.countAdvice();
        for (BaseChartDTO baseChartDTO : baseChartDTOS) {
            switch (baseChartDTO.getName()) {
                case "1":
                    baseChartDTO.setName("不满意");
                    break;
                case "2":
                    baseChartDTO.setName("满意");
                    break;
                default:
                    baseChartDTO.setName("非常满意");
            }
        }
        return baseChartDTOS;
    }
}
